package com.projectplace.api.objectResponses.Conversation;

/*
 * Copyright (c) 2011 Projectplace International AB
 * Permission is hereby granted, free of charge, to any person 
 * obtaining a copy of this software and associated documentation 
 * files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, 
 * publish, distribute, sublicense, and/or sell copies of the Software, 
 * and to permit persons to whom the Software is furnished to do so, 
 * subject to the following conditions:The above copyright notice and this 
 * permission notice shall be included in all copies or substantial portions of the Software.
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */


import java.util.List;



public class Conversation{
	
	private String id;
	private List<Posts> posts;
	private List<String> liked_by;
	private String last_post_time;
	private int post_count;
	
	@Override
	public boolean equals( Object other )
    {
		if(other instanceof Conversation){
			Conversation tempCheck = (Conversation) other;
			if(id != null  && tempCheck.getId() != null)
		        return id.equals(tempCheck.getId());
		    else
		        return false;
		}else
			return false;
    }
	
	@Override
	public int hashCode(){
		String temp = id;
		temp += last_post_time;
		return temp.hashCode();
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public List<Posts> getPosts() {
		return posts;
	}
	public void setPosts(List<Posts> posts) {
		this.posts = posts;
	}
	public List<String> getLiked_by() {
		return liked_by;
	}
	public void setLiked_by(List<String> liked_by) {
		this.liked_by = liked_by;
	}
	public String getLast_post_time() {
		return last_post_time;
	}
	public void setLast_post_time(String last_post_time) {
		this.last_post_time = last_post_time;
	}
	public int getPost_count() {
		return post_count;
	}
	public void setPost_count(int post_count) {
		this.post_count = post_count;
	}	
	
	public void clear(){
		if(posts != null)
			posts.clear();
		if(liked_by != null)
			liked_by.clear();
	}
	
	public int size(){
		return posts.size();
	}
	
	public Posts getPostByIndex(int index){
		return posts.get(index);
	}
}

